/**
 * 
 */
package org.skyfree.ghyll.tcard.view;

import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.skyfree.ghyll.tcard.Activator;
import org.skyfree.ghyll.tcard.core.ITCard;
import org.skyfree.ghyll.tcard.core.ITProject;
import org.skyfree.ghyll.tcard.core.ITWorkpiece;

class WSViewLabelProvider extends LabelProvider 
{
	static Image ICON_Project = Activator.getImageDescriptor("icons/project.png").createImage();
	static Image ICON_WP = Activator.getImageDescriptor("icons/workpiece0.png").createImage();
	static Image ICON_WP_InPro = Activator.getImageDescriptor("icons/workpiece.gif").createImage();
	static Image ICON_WP_LINK = Activator.getImageDescriptor("icons/link.png").createImage();
	static Image ICON_Card = Activator.getImageDescriptor("icons/card.jpg").createImage();
	
	public String getText(Object element) 
	{
		if(element instanceof ITProject)
		{
			return ((ITProject)element).getName();
		}
		else if(element instanceof ITWorkpiece)
		{
			return ((ITWorkpiece)element).getName();
		}
		return super.getText(element);
	}
	public Image getImage(Object element) 
	{
		if(element instanceof ITProject)
		{
			return ICON_Project;
		}
		else if(element instanceof ITWorkpiece)
		{
			ITWorkpiece wp = (ITWorkpiece)element;
			if(wp.isInProgress())return ICON_WP_InPro;
			else if(wp.getStorageType().equals(ITWorkpiece.STT_Link))
				return ICON_WP_LINK;
			else return ICON_WP;
		}
		else if(element instanceof ITCard)
		{
			return ICON_Card;
		}
		return null;
	}
}